package test_package;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.Assert;

/**
 * Created by IIGalytska on 01.04.14.
 */
public class CheckoutPage {
    private WebDriver driver;

    public CheckoutPage(WebDriver driver){

        this.driver = driver;

    }


    public ConfirmationPage fillInDataPositive(String name, String mobile, String email ){

        WebElement inputElement = driver.findElement(By.id("reciever_name"));
        inputElement.clear();
        inputElement.sendKeys(name);
        Assert.assertEquals(name, inputElement.getAttribute("value"));

        driver.findElement(By.xpath("/html/body/div/div/section/div[2]/div/div/div/form/section/div/div/div/div[2]/div[2]/div/div/div[2]/a")).click();


        WebElement inputElement2 = driver.findElement(By.id("reciever_phone"));
        inputElement2.clear();
        inputElement2.sendKeys(mobile);

        Assert.assertEquals(mobile, inputElement2.getAttribute("value"));


        WebElement inputElement3 = driver.findElement(By.id("reciever_email"));
        inputElement3.clear();
        inputElement3.sendKeys(email);

        Assert.assertEquals(email, inputElement3.getAttribute("value"));




        driver.findElement(By.id("continue_button")).click();



        return new ConfirmationPage(driver);
    }
}